package com.eastfair.venuebooking.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.boot.request.PageParams;
import com.eastfair.boot.service.SuperService;
import com.eastfair.core.base.R;
import com.eastfair.venuebooking.dto.ExhibitionDTO;
import com.eastfair.venuebooking.dto.ExhibitionQuery;
import com.eastfair.venuebooking.dto.ExhibitionUpdateDTO;
import com.eastfair.venuebooking.entity.Exhibition;
import com.eastfair.venuebooking.entity.VenueBookAudit;
import com.eastfair.venuebooking.enumeration.ExhibitionStateEnum;
import com.eastfair.venuebooking.vo.ExhibitionVO;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 业务接口
 * 展会
 * </p>
 *
 * @author linan
 * @date 2022-06-08
 */
public interface ExhibitionService extends SuperService<Exhibition> {

    /**
     * 添加展会
     * @param exhibitionSaveDTO
     * @return
     */
    R addExhibition(ExhibitionDTO exhibitionSaveDTO);

    /**
     * 更新展会信息
     * @param exhibitionUpdateDTO
     * @return
     */
    R updateExhibition(ExhibitionDTO exhibitionUpdateDTO);

    /**
     * 同步展会
     * @param exhibition
     */
    void updateAutoSegment(Exhibition exhibition);

    /**
     * selectExhibitionAndSpace
     * @param exhibitionId
     * @return
     */
    List<Map<String, Object>> selectExhibitionAndSpace(Long exhibitionId);

    /**
     * 更新商机id.
     *
     * @param updateDTO the update dto
     * @return the boolean
     */
    boolean updateBusinessOpportunityId(ExhibitionUpdateDTO updateDTO);

    /**
     * 通过商机id查询展会.
     *
     * @param opportunityId the opportunity id
     * @return the exhibition
     */
    Exhibition selectExhibitionByOpportunityId(Long opportunityId);

    /**
     * 项目进度、场地预订情况、合同金额、任务执行
     * @param exhibitionId
     * @return
     */
    Map<String, Object> getStatisticalItems(Long exhibitionId);

    /**
     * 外部展会ID获取展会.
     *
     * @param externalExhibitionCode the external exhibition code
     * @return the by external exhibition code
     */
    Exhibition getByExternalExhibitionCode(String externalExhibitionCode);

    /**
     * 统筹书展示
     * @param exhibitionId
     * @param date
     * @param exhibition
     * @param result
     */
    Map<String, Object> getCoordinationBookView(Long exhibitionId, LocalDate date, Exhibition exhibition, Map<String, Object> result);

    /**
     * 展会列表
     * @param params
     * @return
     */
    IPage<ExhibitionVO> queryExhibitionList(PageParams<ExhibitionQuery> params);

    /**
     * 修改展会状态
     * @param exhibitionId
     * @param state
     * @return
     */
    Boolean updateExhibitionState(Long exhibitionId, ExhibitionStateEnum state);

    /**
     * 近期展览/会议/其他
     * @param params
     * @return
     */
    IPage<ExhibitionVO> queryRecentExhibitionList(PageParams<ExhibitionQuery> params);

    /**
     * 展会日历
     * @param keywords
     * @return
     */
    Map<String, Object> getExhibitionCalendar(String keywords);

    /**
     * 根据合同付款结果处理展会状态
     * @param exhibitionId
     */
    void dealPaidResult(Long exhibitionId);

    /**
     * 通过客户ID统计展会数量.
     *
     * @param customerId the customer id
     * @return the long
     */
    long countExhibitionByCustomerId(Long customerId);

    /**
     * 展会是否存在.
     *
     * @param query query
     * @return the boolean true：存在/false：不存在
     */
    boolean existExhibition(ExhibitionQuery query);

    /**
     * 通过客户ID查询展会是否存在.
     *
     * @param customerId the customer id
     * @return the boolean true：存在/false：不存在
     */
    boolean existExhibitionByCustomerIds(List<Long> customerId);

    /**
     * 商机ID查询展会是否存在.
     *
     * @param businessOpportunityIds the business opportunity ids
     * @return the boolean
     */
    boolean existExhibitionByBusinessOpportunityIds(List<Long> businessOpportunityIds);

    /**
     * 复制展会
     * @param exhibitionSaveDTO
     * @return
     */
    R copyExhibition(ExhibitionDTO exhibitionSaveDTO);

    /**
     * 同步展会
     * @param exhibition exhibition
     */
    void syncExhibition(Exhibition exhibition);

    /**
     * 同步综合展会管理信息
     * @param exhibitionDTO exhibitionDTO
     * @return Boolean
     */
    Boolean syncExhibitionManage(ExhibitionDTO exhibitionDTO);


    /**
     * 确认展会
     * @param exhibitionId exhibitionId
     * @return Boolean
     */
    Boolean updateConfirmExhibition(Long exhibitionId);

    /**
     * 校验展会的编辑是否影响合同.
     *
     * @param updateDTO the update dto
     * @return the boolean
     */
    boolean checkIsUpdateContract(ExhibitionDTO updateDTO);

    /**
     * 查询展会未同步的所有展会
     * @return
     */
    List<ExhibitionVO> queryNeedSyncExhibition();

    /**
     * 场馆预定审核通过生成展会.
     *
     * @param venueBookAudit the website venue book dto
     * @param customerMainId      the customer main id
     * @param customerMainName    the customer main name
     * @param contactId           the contact id
     * @param contactName         the contact name
     * @return the long
     */
    Long saveForVenueBook(VenueBookAudit venueBookAudit, Long customerMainId, String customerMainName, Long contactId, String contactName);

    /**
     * 校验是否存在同期展会
     * @param exhibitionDTO exhibitionDTO
     * @return Boolean
     */
    Object checkSamePeriodExhibition(ExhibitionDTO exhibitionDTO);

    /**
     * 同步展会到外部小程序
     * @param exhibition
     */
    void syncExhibitionToOutside(Exhibition exhibition);

    /**
     * 更新展会状态
     * @param asList
     */
    void updateExhibitionState(List<Long> asList);
}
